﻿using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp.Demos.SimplePipeline
{
    // IHostedService 接口是框架提供的
    public class WebHostedServiceByCustom : IHostedService
    {
        private readonly IServerByCustom _server;
        private readonly RequestDelegateByCustom _handler;

        public WebHostedServiceByCustom(IServerByCustom server, RequestDelegateByCustom handler)
        {
            _server = server;
            _handler = handler;
        }

        public Task StartAsync(CancellationToken cancellationToken)
            => _server.StartAsync(_handler);


        public Task StopAsync(CancellationToken cancellationToken)
            => Task.CompletedTask;
    }
}
